package com.qujia.station.utils;

import java.util.Collection;
import java.util.List;
import java.util.stream.Collectors;
import java.util.stream.Stream;

public class SplitListUtils {
    public static <T> List<List<T>> splitList(int offset, int dataSize, Collection<T> dataList) {
        return Stream.iterate(0, i -> i + 1).limit((int) Math.ceil((float) dataSize / offset)).parallel().map(
                        n -> dataList.stream().skip(n * offset).limit(offset).parallel().collect(Collectors.toList()))
                .collect(Collectors.toList());
    }
}

